package com.yanmaohu.yulia.bean;

/**
 * @author Bright Lee
 */
public final class AttributeOrMethodReference implements NonparenthesizedValueExpressionPrimary {

    private int beginIndex;
    private int endIndex;
    private ValueExpressionPrimary valueExpressionPrimary;
    private RightArrow dereferenceOperator;
    private Identifier qualifiedIdentifier;
    private SqlArgumentList sqlArgumentList;

    public AttributeOrMethodReference(ValueExpressionPrimary valueExpressionPrimary,
                                      RightArrow dereferenceOperator,
                                      Identifier qualifiedIdentifier,
                                      SqlArgumentList sqlArgumentList) {
        this.beginIndex = valueExpressionPrimary.getBeginIndex();
        this.endIndex = sqlArgumentList != null ? sqlArgumentList.getEndIndex() : qualifiedIdentifier.getEndIndex();
        this.valueExpressionPrimary = valueExpressionPrimary;
        this.dereferenceOperator = dereferenceOperator;
        this.qualifiedIdentifier = qualifiedIdentifier;
        this.sqlArgumentList = sqlArgumentList;
    }

    @Override
    public int getBeginIndex() {
        return beginIndex;
    }

    @Override
    public int getEndIndex() {
        return endIndex;
    }

    public ValueExpressionPrimary getValueExpressionPrimary() {
        return valueExpressionPrimary;
    }

    public RightArrow getDereferenceOperator() {
        return dereferenceOperator;
    }

    public Identifier getQualifiedIdentifier() {
        return qualifiedIdentifier;
    }

    public SqlArgumentList getSqlArgumentList() {
        return sqlArgumentList;
    }

}
